﻿using System.Web.UI;

namespace NativeCode.Web.Extensions
{
	public static class StateBagExtensions
	{
		public static T Read<T>(this StateBag bag, string name)
		{
			object value = bag[name];
			if (value == null)
			{
				return default(T);
			}

			return (T) value;
		}

		public static void Write<T>(this StateBag bag, string name, T value)
		{
			bag[name] = value;
		}
	}
}